package by.grsu.perovskij.page;

import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.spring.injection.annot.SpringBean;

import by.grsu.perovskij.dao.PassengerWagonDao;
import by.grsu.perovskij.entity.PassengerWagon;

@SuppressWarnings("serial")
public class ListPassengerWagonsPage extends BasePage {
	@SpringBean
	private PassengerWagonDao passengerWagonDao;
	
	public ListPassengerWagonsPage() {
		super();
		
		final List<PassengerWagon> passengerWagons = passengerWagonDao.findAll();

		add(new ListView<PassengerWagon>("list", passengerWagons) {
			@Override
			protected void populateItem(final ListItem<PassengerWagon> item) {
				final PassengerWagon passengerWagon = item.getModelObject();
				item.add(new Label("trainId", String.valueOf(passengerWagon.getTrain().getId())));
				item.add(new Label("comfortLevel", passengerWagon.getComfort().name()));
				item.add(new Label("capacity", String.valueOf(passengerWagon.getCapacity())));
				item.add(new Label("quantity", String.valueOf(passengerWagon.getQuantity())));
				/*
				 * item.add(new Link<PassengerWagon>("editLink",new Model<PassengerWagon>(passengerWagon)){
				 * 
				 * @Override public void onClick(){ setResponsePage(new
				 * EditPassengerWagon(passengerWagon)); } });
				 */
			}
		});
		/*
		 * add(new Link<PassengerWagon>("createLink", new Model<PassengerWagon>(new Bill())) {
		 * 
		 * @Override public void onClick() { setResponsePage(new
		 * EditPassengerWagon(getModelObject())); } });
		 */
	}

}
